package routers

import (
	"github.com/gin-gonic/gin"
	"likeadmin/admin/schemas/req"
	"likeadmin/core"
	"likeadmin/frontend/service"
	"net/http"
)

var UserGroup = core.Group("/user", newUserHandler, regUser)

func newUserHandler(srv service.IUserService) *userHandler {
	return &userHandler{srv: srv}
}

func regUser(rg *gin.RouterGroup, group *core.GroupBase) error {
	return group.Reg(func(handle *userHandler) {
		rg.GET("/list", handle.list)

	})
}

type userHandler struct {
	srv service.IUserService
}

// login 登录系统

func (lh userHandler) list(c *gin.Context) {
	var loginReq req.SystemLoginReq
	//if response.IsFailWithResp(c, util.VerifyUtil.VerifyJSON(c, &loginReq)) {
	//	return
	//}
	list, err := lh.srv.List(c, &loginReq)
	if err != nil {
		return
	}
	c.JSON(http.StatusOK, list)
}
